﻿create procedure [dbo].[usp_ExceptionUpdate] 
	@ExceptionId int
	, @ConcurrencyId timestamp
	, @PublicationId uniqueidentifier
	, @AppDomainId int
	, @AssemblyId int
	, @MachineId int
	, @ProcessId int
	, @TargetSiteId int
	, @ThreadId int
	, @WorkItemId int
	, @ExceptionType nvarchar(255)
	, @HelpLink nvarchar(512)
	, @HResult int
	, @IsTransient bit
	, @Message nvarchar(512)
	, @Source nvarchar(512)
	, @StackTrace nvarchar(max)
	, @Unhandled bit
	, @SerializedExceptionXml xml
	, @SerializedIIdentityXml xml
	, @IIdentityName nvarchar(255)
	, @IIdentityIsAuthenticated bit
	, @IIdentityAuthenticationType nvarchar(255)
as

begin try
	
	begin transaction
	
		update [dbo].[Exception]
		set
			PublicationId = @PublicationId
			, AppDomainId = @AppDomainId
			, AssemblyId = @AssemblyId
			, MachineId = @MachineId
			, ProcessId = @ProcessId
			, TargetSiteId = @TargetSiteId
			, ThreadId = @ThreadId
			, WorkItemId = @WorkItemId
			, ExceptionType = @ExceptionType
			, HelpLink = @HelpLink
			, HResult = @HResult
			, IsTransient = @IsTransient
			, Message = @Message
			, Source = @Source
			, StackTrace = @StackTrace
			, Unhandled = @Unhandled
			, SerializedExceptionXml = @SerializedExceptionXml
			, SerializedIIdentityXml = @SerializedIIdentityXml
			, IIdentityName = @IIdentityName
			, IIdentityIsAuthenticated = @IIdentityIsAuthenticated
			, IIdentityAuthenticationType = @IIdentityAuthenticationType
		where ExceptionId = @ExceptionId and ConcurrencyId = @ConcurrencyId
		
	commit transaction

end try
	
begin catch
	if @@trancount > 0
	begin
		rollback transaction;
	end
	execute [dbo].[usp_SqlErrorInsert]
end catch